﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClientRegister
{
    public partial class ListTeacherForm : Form
    {
        public ListTeacherForm()
        {
            InitializeComponent();
        }

        TeacherDataProvider teacher = new TeacherDataProvider();
        SynchronizeData sync = new SynchronizeData();

        private void ListTeacherForm_Load(object sender, EventArgs e)
        {
            gridListTeacher.DataSource = teacher.SelectAllTeacher().Tables[0];
        }

        private void btnChange_Click(object sender, EventArgs e)
        {

        }

        private void btnRemove_Click(object sender, EventArgs e)
        {
            if (gridListTeacher.SelectedCells.Count > 0)
            {
                string ID = gridListTeacher.CurrentRow.Cells["ID"].Value.ToString();
                string xml = teacher.SelectAndConvertXMLTech(ID);
                if(teacher.deleteTeacher(ID) != 0)
                {
                    sync.transfDataForDeleteMethod(xml, sync.TeacherTb);
                    MessageBox.Show("Đã xóa");
                }
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnRefesh_Click(object sender, EventArgs e)
        {
            gridListTeacher.DataSource = teacher.SelectAllTeacher().Tables[0];
        }
    }
}
